<%@page isELIgnored="false" pageEncoding="UTF-8" contentType="text/html; UTF-8" %>
	<script type="text/javascript">
		$(function () {
            $('#logDatagrid').datagrid({
                url:'${pageContext.request.contextPath}/log/selectLogDatagrid',
                method:"get",
                pagination:true,
                columns:[[
                    //一旦加上复选框属性，页面展示不出来效果，刷新后表格对不齐
					{field:'恶心',title:'复选框',checkbox:true},
                    {field:'logId',title:'日志编号',width:50,align:"center"},
                    {field:'adminUsername',title:'用户名',width:150,align:"center"},
                    {field:'logDate',title:'登录时间',width:150,align:"center"},
                    {field:'logContent',title:'描述',width:150,align:"center"},
                    {field:'logIp',title:'用户IP',width:100,align:"center"}
                ]],
                toolbar: '#myLogTooBar'
            });

      
        });


		// 批量删除日志
        function doDeleteSomeLogs() {
			var allSelectionRows=$("#logDatagrid").datagrid("getSelections");
			if(allSelectionRows.length==0){
			    alert("请选择要删除的数据！");
			}else{
                var isConfirm=confirm("请确认是否删除？");
                if(isConfirm){
                    var allIds=new Array(allSelectionRows.length);
                    for(var i=0;i<allIds.length;i++){
                        allIds[i]=allSelectionRows[i].logId;
                    }
                    //发送ajax请求
                    $.ajax({
                        url:"${pageContext.request.contextPath}/log/deleteLogs",
                        data:"ids="+allIds,
                        success:function(data){
                            //删除成功，刷新页面
                            if(data.isDelete){
                                $("#logDatagrid").datagrid("reload");
                            }else{
                                alert("删除失败，请确认！");
                            }
                        }
                    })
				}
			}
        }
	</script>
	<div id="myLogTooBar">
		<a class="easyui-linkbutton" onclick="doDeleteSomeLogs()">删除</a>
	</div>
	<table id="logDatagrid"></table>
